package com.zenith.yasoo.party;

import javax.annotation.Resource;

import org.apache.commons.lang.RandomStringUtils;

import com.zui.base.EntityManagerImpl;
import com.zui.util.mail.MailManager;

public class SignupManagerImpl extends EntityManagerImpl implements SignupManager {


	@Resource
	private PersonManager personManager;
	@Resource
	private MailManager mailManager;
	@Resource
	private MailManager jmsMailManager;

	public void signup(Person person) {

		// generate a random validation code.

		person.setStatus(Person.STATUS_UNCONFIRMED);
		person.setConfirmCode(RandomStringUtils.random(8, true, true));
		personManager.saveEntity(person);

		if (MailManager.JMS_MAIL_MANAGER)
			jmsMailManager.sendSignupConfirmationMessage(person);
		else
			mailManager.sendSignupConfirmationMessage(person);
	}
}
